package edu.ynu.se.xiecheng.achitectureclass.nongye.controller;

import edu.ynu.se.xiecheng.achitectureclass.nongye.dao.ConductivityDAO;
import edu.ynu.se.xiecheng.achitectureclass.nongye.entity.Conductivity;
import edu.ynu.se.xiecheng.achitectureclass.nongye.service.ConductivityService;
import edu.ynu.se.xiecheng.achitectureclass.common.controller.LogicController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "电导率管理")
@RestController
@RequestMapping("/conductivity")
public class ConductivityController extends LogicController<ConductivityService, ConductivityDAO, Conductivity, Integer> {

    @Autowired
    public ConductivityController(ConductivityService conductivityService) {
        super(conductivityService);
    }

    @ApiOperation("根据ID获取电导率信息")
    @GetMapping("/getconductivity")
    public Conductivity getConductivityById(@RequestParam Integer id) {
        return getService().GET(id);
    }

    @ApiOperation("获取所有电导率信息")
    @GetMapping("/getAllconductivity")
    public List<Conductivity> getAllConductivity() {
        return getService().getAll();
    }

    @ApiOperation("创建电导率记录")
    @PostMapping("/postconductivity")
    public Conductivity createConductivity(@RequestBody Conductivity conductivity) {
        return getService().POST(conductivity);
    }

    @ApiOperation("更新电导率记录")
    @PostMapping("/putconductivity")
    public Conductivity updateConductivity(@RequestBody Conductivity conductivity) {
        return getService().PUT(conductivity);
    }

    @ApiOperation("删除电导率记录")
    @PostMapping("/deleteconductivity")
    public void deleteConductivity(@RequestBody Conductivity conductivity) {
        getService().DELETE(conductivity);
    }

    @ApiOperation("通过ID删除电导率记录")
    @GetMapping("/deleteByIdconductivity")
    public void deleteConductivityById(@RequestParam Integer id) {
        getService().DELETE(id);
    }
}
